package org.particlethink.service;

import com.github.pagehelper.PageInfo;
import org.particlethink.auth.DefaultUser;
import org.particlethink.entry.DeliverStatus;
import org.particlethink.model.Deliver;
import org.particlethink.model.User;
import org.particlethink.request.AcceptSubOrderRequest;
import org.particlethink.request.DeliveryGood;
import org.particlethink.response.DeliverExportResponse;
import org.particlethink.response.DeliverResponse;
import org.particlethink.response.DeliverStatusCountResponse;
import org.particlethink.response.OrderStatusCountResponse;

import java.util.Date;
import java.util.List;

/**
 * 子订单相关逻辑
 * 注：子订单同发货单
 */
public interface SubOrderService {
    /**
     * 项目人员拒签子订单
     *
     * @param userID     拒签操作人
     * @param subOrderID 拒签的子订单编号
     */
    void reject(List<Integer> projectIds, Integer userID, Integer subOrderID);


    /**
     * 项目人员验收子订单
     *
     * @param request
     */
    void accept(List<Integer> projectIds, Integer userId, AcceptSubOrderRequest request);

    /**
     * 项目人员修改验收
     *
     * @param request
     */
    void edit(List<Integer> projectIds, AcceptSubOrderRequest request, Integer id);

    /**
     * 暂存
     *
     * @param request
     */
    void preserve(AcceptSubOrderRequest request, Integer userId);

    /**
     * 供应商确认子订单
     *
     * @param userID     供应商用户
     * @param subOrderID 相关子订单
     */
    void confirm(Integer userID, Integer subOrderID);

    /**
     * 供应商异议
     *
     * @param userID          供应商用户
     * @param subOrderID      相关子订单
     * @param objectionReason 异议原因
     */
    void objection(Integer userID, Integer subOrderID, String objectionReason);

    /**
     * 供应商创建子订单信息（供应商发货）
     *
     * @param userID        操作人
     * @param orderID       发货的订单
     * @param deliveryGoods 发货详情信息
     * @param finishTime    预计到达时间
     * @param remark        备注
     */
    void create(Integer userID, Integer orderID, List<DeliveryGood> deliveryGoods, Date finishTime, String remark, String receiverName, String receiverPhone, String receiverAddress);

    /**
     * 查询发货单（子订单）
     *
     */
    PageInfo<DeliverResponse> queryDeliver(
            DefaultUser user,
            String managementLevel,
            Integer projectId,
            String deliverNo,
            String orderNo,
            Integer categoryName,
            String carNumber,
            String supplierUserName,
            String acceptanceUserName,
            Date acceptanceStart,
            Date acceptanceEnd,
            Integer supplierId,
            DeliverStatus status,
            Boolean shouldBilled,
            Date submitStart,
            Date submitEnd,
            String searchKey,
            Integer pageNum,
            Integer pageSize
    );

    PageInfo<DeliverResponse> queryNo(User user, DeliverStatus status, String no);

    List<DeliverExportResponse> export(
            User user,
            String managementLevel,
            Integer projectId,
            String deliverNo,
            String orderNo,
            Integer categoryName,
            String carNumber,
            String supplierUserName,
            String acceptanceUserName,
            Date acceptanceStart,
            Date acceptanceEnd,
            Integer supplierId,
            DeliverStatus status,
            Date submitStart,
            Date submitEnd
    );

//    /**
//     * 查询订单下的所有子订单（发货单）
//     * @param userID 查询用户的ID
//     * @param orderID 查询的订单
//     * @return
//     */
//    List<Deliver> queryDeliver(Integer userID, DeliverStatus status,Integer orderID);

//    List<Deliver> queryDeliver(List<DeliverStatus> status, Integer orderID);

    void remark(List<Integer> supplierIds, int deliverId, String remark);

    void cancel(List<Integer> projectIds, int deliverId, String remark);

    void reAccept(List<Integer> projectIds, Integer deliverId);


    DeliverStatusCountResponse countOrdersByStatus(List<Integer> supplierIds, List<Integer> projectIds);
}
